<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/_mozilla/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';
promise_test(t => {
    window.testRunner.setBluetoothMockDataSet(adapter_type.heart_rate);
    return window.navigator.bluetooth.requestDevice({
        filters: [{services: [heart_rate.name]}]
    })
    .then(device => device.gatt.connect())
    .then(gattServer => {
        return gattServer.getPrimaryService(heart_rate.name)
        .then(service => {
            let promise = promise_rejects_dom(t, 'NetworkError', service.getCharacteristics(body_sensor_location.alias));
            gattServer.disconnect();
            return promise;
        });
    });
}, 'disconnect() called during getCharacteristics. Reject with NetworkError.');
</script>

